import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:ls_work/viewmodel/use_request/use_request_record_view_model.dart';

import 'add_use_request_page.dart';
import 'new_add_use_request_page.dart';

class UseRequestRecordPage extends BaseStatefulMvvmWidget {
  @override
  State<StatefulWidget> createState() => _UseRequestRecordState();
}

class _UseRequestRecordState
    extends BaseMvvmListState<UseRequestRecordViewModel, UseRequestRecordPage> {
  @override
  Widget buildRootView(BuildContext context, Widget loadingContentWidget) {
    return Scaffold(
      appBar: AppBar(
        title: Text("领用记录"),
        actions: [TextButton(onPressed: () {
          // Go().push(AddUseRequestPage());
          Go().push(NewAddUseRequestPage());
        }, child: Text("新增领用"))],
      ),
      body: loadingContentWidget,
    );
  }

  @override
  Widget buildLoadingContentView() {
    return Column(
      children: [
        Row(
          children: [
            CommonText("申请时间",textSize: 14).setWeight(1),
            CommonText("申请单号",textSize: 14).setWeight(1),
            Container(width: 10,),
            CommonText("状态",textSize: 14).setWeight(1),
            CommonText("申请人",textSize: 14).setWeight(1),
            Container(
              width: 20,
            )
          ],
        ).addToContainer(
            padding: EdgeInsets.symmetric(vertical: 15, horizontal: 16)),
        DashLine(
          axis: Axis.horizontal,
          dashedWidth: 5,
          count: 40,
          dashedHeight: 0.5,
          color: Colors.grey,
        ).addToContainer(padding: EdgeInsets.symmetric(horizontal: 16)),
        super.buildLoadingContentView()!.setWeight(1)
      ],
    );
  }

  @override
  Widget createItemWidget(int index) {
    var item = viewModel.listItems[index];
    return Row(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        CommonText("${item.createdDate}",textSize: 14).setWeight(1),
        CommonText("${item.applicationNo}",textSize: 14).setWeight(1),
        Container(width: 10,),
        CommonText("${item.statusName}",textSize: 14).setWeight(1),
        CommonText("${item.applyPerson}",textSize: 14).setWeight(1),
        Icon(Icons.arrow_forward_ios_rounded,size: 20,)
      ],
    ).onTap(() {
      Go().push(NewAddUseRequestPage(recordId: item.id,));
    }).addToContainer(
        padding: EdgeInsets.symmetric(vertical: 15, horizontal: 16));
  }

  @override
  UseRequestRecordViewModel createViewModel() {
    return UseRequestRecordViewModel(context);
  }

  @override
  bool get canPullUp => true;

  @override
  Widget get separatorDivider => Container(height: 1,color: Colors.grey,margin: EdgeInsets.symmetric(horizontal: 16),);


  
}

